home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedeApplet.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  5.7 KB  |  230 lines

  1. package com.supercede.forms;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Graphics;
  7. import java.awt.Point;
  8. import java.io.IOException;
  9. import java.io.InvalidObjectException;
  10. import java.io.ObjectInputStream;
  11. import java.io.Serializable;
  12. import java.util.Vector;
  13.  
  14. public class SuperCedeApplet extends Applet implements SuperCedeDesignContainer, Serializable {
  15.    SuperCedeRuntimeInfo runtimeInfo = new SuperCedeRuntimeInfo();
  16.    SuperCedeDesignInfo designInfo = new SuperCedeDesignInfo();
  17.    transient boolean designMode = false;
  18.    transient DesignModeListener formListener = null;
  19.    transient Vector scContainerListeners = null;
  20.    boolean shadowEnabled = super.isEnabled();
  21.    Point shadowLocation = new Point(0, 0);
  22.    private static final long serialVersionUID = 1013082004010516610L;
  23.    private static final int _version = 1;
  24.    private int version = 1;
  25.  
  26.    public final void initializeThis(Vector var1) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException {
  27.       this.designInfo = null;
  28.       this.runtimeInfo = null;
  29.       SuperCedeHelper.runTimeConstructor(this, var1);
  30.       ((Component)this).setLocation(this.shadowLocation);
  31.       this.validateObject();
  32.    }
  33.  
  34.    public Component[] getContainedComponents() {
  35.       return ((Container)this).getComponents();
  36.    }
  37.  
  38.    public void initializeFrom(SuperCedeContainer var1) throws ClassCastException, SuperCedeInvalidStateException {
  39.       try {
  40.          this.setDesignMode(((SuperCedeDesignContainer)var1).isDesignMode());
  41.          this.setFormListener(((SuperCedeDesignContainer)var1).getFormListener());
  42.          this.runtimeInfo = var1.getRuntimeInfo();
  43.          this.designInfo = ((SuperCedeDesignContainer)var1).getDesignInfo();
  44.          SuperCedeHelper.convertContainer((Container)var1, this);
  45.          if (!this.isDesignMode()) {
  46.             this.runtimeInfo = null;
  47.             this.designInfo = null;
  48.          }
  49.       } catch (ClassCastException var3) {
  50.          throw var3;
  51.       }
  52.    }
  53.  
  54.    public SuperCedeDesignInfo getDesignInfo() {
  55.       return this.designInfo;
  56.    }
  57.  
  58.    public SuperCedeRuntimeInfo getRuntimeInfo() {
  59.       return this.runtimeInfo;
  60.    }
  61.  
  62.    public void addComponent(Component var1, Object var2) {
  63.       this.addComponent(var1, var2, -1);
  64.    }
  65.  
  66.    public void addComponent(Component var1, Object var2, int var3) {
  67.       this.add(var1, var2, var3);
  68.       this.runtimeInfo.addLayoutConstraints(var1, var2);
  69.    }
  70.  
  71.    public void add(Component var1, Object var2, int var3) {
  72.       super.add(var1, var2, var3);
  73.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  74.          ((Applet)var1).start();
  75.       }
  76.  
  77.    }
  78.  
  79.    public void removeComponent(int var1) {
  80.       this.removeComponent(((Container)this).getComponent(var1));
  81.    }
  82.  
  83.    public void removeComponent(Component var1) {
  84.       this.runtimeInfo.removeLayoutConstraints(var1);
  85.       this.remove(var1);
  86.    }
  87.  
  88.    public void remove(Component var1) {
  89.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  90.          ((Applet)var1).stop();
  91.       }
  92.  
  93.       super.remove(var1);
  94.    }
  95.  
  96.    public boolean isEnabled() {
  97.       return this.shadowEnabled;
  98.    }
  99.  
  100.    public void setEnabled(boolean var1) {
  101.       this.shadowEnabled = var1;
  102.       if (!this.isDesignMode()) {
  103.          super.setEnabled(var1);
  104.       }
  105.  
  106.    }
  107.  
  108.    public void paint(Graphics var1) {
  109.       if (this.formListener != null) {
  110.          this.formListener.paint(var1);
  111.       }
  112.  
  113.       super.paint(var1);
  114.    }
  115.  
  116.    public void addNotify() {
  117.       if (this.formListener != null) {
  118.          this.formListener.setupParentHWND();
  119.       }
  120.  
  121.       super.addNotify();
  122.       if (this.formListener != null) {
  123.          this.formListener.addedPeer();
  124.       }
  125.  
  126.    }
  127.  
  128.    public void removeNotify() {
  129.       if (this.formListener != null) {
  130.          this.formListener.removingPeer();
  131.       }
  132.  
  133.       super.removeNotify();
  134.    }
  135.  
  136.    public Object getLayoutConstraints(Component var1) {
  137.       return this.runtimeInfo.getLayoutConstraints(var1);
  138.    }
  139.  
  140.    public Object getLayoutConstraints(int var1) {
  141.       return this.getLayoutConstraints(((Container)this).getComponent(var1));
  142.    }
  143.  
  144.    public void setDesignMode(boolean var1) {
  145.       this.designMode = var1;
  146.    }
  147.  
  148.    public boolean isDesignMode() {
  149.       return this.designMode;
  150.    }
  151.  
  152.    public void setFormListener(DesignModeListener var1) {
  153.       this.formListener = var1;
  154.    }
  155.  
  156.    public DesignModeListener getFormListener() {
  157.       return this.formListener;
  158.    }
  159.  
  160.    public void setVisible(boolean var1) {
  161.       if (!var1) {
  162.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), false);
  163.       }
  164.  
  165.       super.setVisible(var1);
  166.       if (var1) {
  167.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), true);
  168.       }
  169.  
  170.    }
  171.  
  172.    public void destroy() {
  173.       if (this.scContainerListeners != null) {
  174.          SuperCedeContainerEvent var2 = new SuperCedeContainerEvent(this, 4434);
  175.          synchronized(this){}
  176.  
  177.          Vector var1;
  178.          try {
  179.             var1 = (Vector)this.scContainerListeners.clone();
  180.          } catch (Throwable var5) {
  181.             throw var5;
  182.          }
  183.  
  184.          for(int var3 = 0; var3 < var1.size(); ++var3) {
  185.             ((SuperCedeContainerListener)var1.elementAt(var3)).containerShutdown(var2);
  186.          }
  187.       }
  188.  
  189.       super.destroy();
  190.    }
  191.  
  192.    public void addSuperCedeContainerListener(SuperCedeContainerListener var1) {
  193.       synchronized(this){}
  194.  
  195.       try {
  196.          if (this.scContainerListeners == null) {
  197.             this.scContainerListeners = new Vector();
  198.          }
  199.  
  200.          this.scContainerListeners.addElement(var1);
  201.       } catch (Throwable var4) {
  202.          throw var4;
  203.       }
  204.  
  205.    }
  206.  
  207.    public void removeSuperCedeContainerListener(SuperCedeContainerListener var1) {
  208.       synchronized(this){}
  209.  
  210.       try {
  211.          this.scContainerListeners.removeElement(var1);
  212.       } catch (Throwable var4) {
  213.          throw var4;
  214.       }
  215.  
  216.    }
  217.  
  218.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  219.       var1.defaultReadObject();
  220.  
  221.       try {
  222.          SuperCedeHelper.doDeserializationProcessing(this);
  223.       } catch (SuperCedeInvalidStateException var2) {
  224.       }
  225.    }
  226.  
  227.    public void validateObject() throws InvalidObjectException {
  228.    }
  229. }
  230.